//将四位数字分割成数组
function splitNumber(number){
    let arr = number.split("");
    return arr;
}

//计算猜对个数
function calculate(randomNumArr,userNumArr){
    let a = 0;
    let b = 0;
    randomNumArr.forEach((eleRandom,indexRandom)=>{
        userNumArr.forEach((eleUser,indexUser)=>{
            if(eleRandom==eleUser && indexRandom==indexUser){
                a++;
            }
            if(eleRandom==eleUser && indexRandom!=indexUser){
                b++;
            }
        })
    })
    return `${a}A${b}B`;
}

module.exports = function main(randomNum,userNum) {
    let randomNumArr = splitNumber(randomNum);
    let userNumArr = splitNumber(userNum);
    let result = calculate(randomNumArr,userNumArr);
    return result;
};

